﻿@using WinformBlazor.Components
@* a *@
@* <div> *@
@if (Data.Type == ContrloType.Form)
{
    <div id="@Data.Id" class="wform container-fluid text-center @(Data.Class.ToString())" style="@(Data.Style.ToString());">
        @foreach (var item in Data.Childs)
        {
            <DControl Data="item" Parent="Data"></DControl>
        }
        <DropArea Control="@Data" Parent="@Parent"></DropArea>
    </div>
}
else if (Data.Type == ContrloType.Panel)
{
    <div id="@Data.Id" class="panel  @(Data.Class.ToString())" style="@(Data.Style.ToString());">
        @foreach (var item in Data.Childs)
        {
            <DControl Data="item" Parent="@Data"></DControl>
        }
        <DropArea Control="@Data" Parent="@Parent"></DropArea>
    </div>

}


else if (Data.Type == ContrloType.Button)
{
    <div id="@Data.Id" class="@Data.Class.ToString()" style="@(Data.Style.ToString());">
        <Button>我是按钮</Button>
        <DropArea Control="@Data" Parent="@Parent"></DropArea>
    </div>
}
else if (Data.Type == ContrloType.CheckBox)
{
    <div id="@Data.Id" class="@Data.Class.ToString()" style="@(Data.Style.ToString());">
        <div>
            <input type="checkbox" id="scales" name="scales" checked />
            <label for="scales">Scales</label>
        </div>
        <DropArea Control="@Data" Parent="@Parent"></DropArea>
    </div>

}
else if (Data.Type == ContrloType.Textbox)
{
    <div id="@Data.Id" class="@Data.Class.ToString()" style="@(Data.Style.ToString());">
        <input value="我是文本框" />
        <DropArea Control="@Data" Parent="@Parent"></DropArea>
    </div>

}
else if (Data.Type == ContrloType.Label)
{
    <div id="@Data.Id" class="col @Data.Class.ToString()" style="@(Data.Style.ToString());">
        <span>我是文本框</span>
        <DropArea Control="@Data" Parent="@Parent"></DropArea>
    </div>

}
else
{
    <span>什么也不是</span>
}
@* </div> *@

@code {

    [Parameter]
    public ControlInfo Data { get; set; } = new();
    [Parameter]
    public ControlInfo? Parent { get; set; }
    // private RenderFragment RenderItemTemplate(IEnumerable<DControlInfo> items) => builder =>
    //    {

    //        foreach (var item in items)
    //        {
    //            builder.AddContent(0, ChildContent(item));
    //        }

    //    };

}
